package ebcs.scan.controller.reviewCtr;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import ebcs.database.bean.BsNeedInfor;
import ebcs.database.bean.BsUserInfor;
import ebcs.database.bean.RpUserReportBean;
import ebcs.database.service.BsUserNeedServiceImp;
import jplat.core.trans.JAppBaseService;
import jplat.core.trans.JAppContext;
import jplat.error.exception.JSystemException;
import jplat.error.exception.JTransException;
import jplat.tools.string.DateUtil;

/**
 * 报工历史查询
 * @author JMY
 *
 */
@Controller
public class HistoryJobCtrl extends JAppBaseService
{
	
	@Autowired
	private BsUserNeedServiceImp userNeedService;
	
	
	// 加载报工历史查询页面
	@RequestMapping("/page/job/historyJob.do")
	public String historyJob( HttpServletRequest request,HttpServletResponse response ) throws JTransException, JSystemException{
		JAppContext context = serviceFactory.buildAppContextWithUser(request,response);		//buildAppContextWithUser 自带客户信息.
 		BsUserInfor user = context.getUserInfo();
 		request.setAttribute("rouid", user.getRouid());
 		String sysDate = DateUtil.getSystemTimeBySomeFormat("yyyyMMdd"); 
 		request.setAttribute("endDate", sysDate);
 		request.setAttribute("startDate", sysDate);
		return "frame/html/job/historyJob";
	}
	
	/**
	 * 查询所选项目组所属需求功能列表 
	 */
	@RequestMapping("/page/job/searchHistoryJob.do")
	public String searchHistoryJob( HttpServletRequest request,HttpServletResponse response,String needName, String needNo, String startDate, String endDate, String rouid ) throws JTransException, JSystemException{
		RpUserReportBean req = new RpUserReportBean();
		req.setEndDate(endDate);
		req.setStartDate(startDate);
		req.setNeedNo(needNo);
		req.setNeedName(needName);
		req.setRouid(rouid);
		List<RpUserReportBean> historyList = this.userNeedService.searchHistoryJob(req);
		request.setAttribute("endDate", endDate);
		request.setAttribute("startDate", startDate);
		request.setAttribute("needNo", needNo);
		request.setAttribute("needName", needName);
		request.setAttribute("rouid", rouid);
		request.setAttribute("list", historyList);
		request.setAttribute("size", historyList.size());
		return "frame/html/job/historyJob";
	}
}
